﻿using MovingChame.Web.Helpers;
using MovingChame.Web.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MovingChame.Web.Services
{
    public static class DataConverter
    {
        public static ScheduleData ConvertToScheduleData(Schedule schedule)
        {
            ScheduleData scheduleData = new ScheduleData()
            {
                Id = schedule.Id,
                StartTime = schedule.StartTime,
                EndTime = schedule.EndTime,
                DateOrder = schedule.DateOrder,
                LocationName = schedule.Location.Name,
                LocationDescription = schedule.Location.LongDescription,
                LocationLatitude = (double)schedule.Location.Center.Latitude,
                LocationLongitude = (double)schedule.Location.Center.Longitude,
                ImageStream = ImageHelper.ConvertImageToByteArray(ImageHelper.ConvertPathToImage(schedule.Location.Id.ToString(),
                    ImageType.LocationImage))
            };
            return scheduleData;
        }

        public static TourData ConvertToTourData(Tour tour)
        {
            TourData tourData = new TourData()
            {
                Id = tour.Id,
                Name = tour.Name,
                Description = tour.Description,
                Summary = tour.Summary,
                Budget = tour.Budget,
                Length = tour.TourLength,
                Type = tour.Type,
                Rating = tour.Rating,
                ImageStream = ImageHelper.ConvertImageToByteArray(ImageHelper.ConvertPathToImage(tour.Id.ToString(),
                    ImageType.TourImage))
            };
            return tourData;
        }
    }
}